package com.jason.demo.servicehi.conc;

import javax.sound.midi.Soundbank;
import java.util.concurrent.LinkedBlockingQueue;

/**
 * @description description
 * @author zhouxinghuai
 * @date 2018-08-23
 */
public class SaveProcessor extends Thread implements RequestProcessor {

    LinkedBlockingQueue<Request> requests = new LinkedBlockingQueue<Request>();


    @Override
    public void process(Request request) {
        requests.add(request);
    }

    @Override
    public void run() {
        while (true) {
            try {
                Request request = requests.take();
                System.out.println("Save data: " + request.getName());
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
